<% layout('/layouts/default.html', {title: '商品管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('商品管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('shop:goods:edit')){ %>
					<a href="${ctx}/shop/goods/form" class="btn btn-default btnTool" title="${text('新增商品')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${goods}" action="${ctx}/shop/goods/listData" method="post" class="form-inline "
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('分类id')}：</label>
					<div class="control-inline">
						<#form:input path="categoryCode" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('扩展分类id')}：</label>
					<div class="control-inline">
						<#form:input path="extendCategoryCode" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品编号')}：</label>
					<div class="control-inline">
						<#form:input path="goodsSn" maxlength="60" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品名称')}：</label>
					<div class="control-inline">
						<#form:input path="goodsName" maxlength="120" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('点击数')}：</label>
					<div class="control-inline">
						<#form:input path="clickCount" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('品牌id')}：</label>
					<div class="control-inline">
						<#form:input path="brandId" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('库存数量')}：</label>
					<div class="control-inline">
						<#form:input path="storeCount" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品评论数')}：</label>
					<div class="control-inline">
						<#form:input path="commentCount" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品重量克为单位')}：</label>
					<div class="control-inline">
						<#form:input path="weight" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品体积。单位立方米')}：</label>
					<div class="control-inline">
						<#form:input path="volume" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('市场价')}：</label>
					<div class="control-inline">
						<#form:input path="marketPrice" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('本店价')}：</label>
					<div class="control-inline">
						<#form:input path="shopPrice" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品成本价')}：</label>
					<div class="control-inline">
						<#form:input path="costPrice" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('价格阶梯')}：</label>
					<div class="control-inline">
						<#form:input path="priceLadder" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品关键词')}：</label>
					<div class="control-inline">
						<#form:input path="keywords" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品简单描述')}：</label>
					<div class="control-inline">
						<#form:input path="goodsSummary" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品详细描述')}：</label>
					<div class="control-inline">
						<#form:input path="goodsContent" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('手机端商品详情')}：</label>
					<div class="control-inline">
						<#form:input path="mobileContent" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品上传原始图')}：</label>
					<div class="control-inline">
						<#form:input path="goodsLogo" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否为虚拟商品 1是，0否')}：</label>
					<div class="control-inline">
						<#form:input path="isVirtual" maxlength="3" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('虚拟商品有效期')}：</label>
					<div class="control-inline">
						<#form:input path="virtualIndate" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('虚拟商品购买上限')}：</label>
					<div class="control-inline">
						<#form:input path="virtualLimit" maxlength="6" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否允许过期退款， 1是，0否')}：</label>
					<div class="control-inline">
						<#form:input path="virtualRefund" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否上架 0-未上架 1-销售中')}：</label>
					<div class="control-inline">
						<#form:input path="isOnSale" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否包邮0否1是')}：</label>
					<div class="control-inline">
						<#form:input path="isFreeShipping" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品上架时间')}：</label>
					<div class="control-inline">
						<#form:input path="onTime" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品排序')}：</label>
					<div class="control-inline">
						<#form:input path="goodsSort" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否推荐0-未推荐 1-已推荐')}：</label>
					<div class="control-inline">
						<#form:input path="isRecommend" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否新品0-不是 1-是')}：</label>
					<div class="control-inline">
						<#form:input path="isNew" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否热卖')}：</label>
					<div class="control-inline">
						<#form:input path="isHot" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品所属类型id，取值表goods_type的id')}：</label>
					<div class="control-inline">
						<#form:input path="goodsType" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品规格类型，取值表goods_type的id')}：</label>
					<div class="control-inline">
						<#form:input path="specType" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('购买商品赠送积分')}：</label>
					<div class="control-inline">
						<#form:input path="giveIntegral" maxlength="8" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('积分兑换')}：</label>
					<div class="control-inline">
						<#form:input path="exchangeIntegral" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('供货商ID')}：</label>
					<div class="control-inline">
						<#form:input path="suppliersId" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品销量')}：</label>
					<div class="control-inline">
						<#form:input path="salesSum" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('0默认1抢购2团购3优惠促销4预售5虚拟')}：</label>
					<div class="control-inline">
						<#form:input path="promType" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('优惠活动id')}：</label>
					<div class="control-inline">
						<#form:input path="promId" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('佣金用于分销分成')}：</label>
					<div class="control-inline">
						<#form:input path="commission" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('SPU')}：</label>
					<div class="control-inline">
						<#form:input path="spu" maxlength="128" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('SKU')}：</label>
					<div class="control-inline">
						<#form:input path="sku" maxlength="128" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('运费模板ID')}：</label>
					<div class="control-inline">
						<#form:input path="templateId" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('视频')}：</label>
					<div class="control-inline">
						<#form:input path="goodsVideo" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('shop_id')}：</label>
					<div class="control-inline">
						<#form:input path="shopId" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注信息')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="500" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('分类id')}', name:'categoryCode', index:'a.category_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/shop/goods/form?goodsId='+row.goodsId+'" class="btnList" data-title="${text('编辑商品')}">'+(val||row.id)+'</a>';
		}},
		{header:'${text('扩展分类id')}', name:'extendCategoryCode', index:'a.extend_category_code', width:150, align:"center"},
		{header:'${text('商品编号')}', name:'goodsSn', index:'a.goods_sn', width:150, align:"left"},
		{header:'${text('商品名称')}', name:'goodsName', index:'a.goods_name', width:150, align:"left"},
		{header:'${text('点击数')}', name:'clickCount', index:'a.click_count', width:150, align:"center"},
		{header:'${text('品牌id')}', name:'brandId', index:'a.brand_id', width:150, align:"center"},
		{header:'${text('库存数量')}', name:'storeCount', index:'a.store_count', width:150, align:"center"},
		{header:'${text('商品评论数')}', name:'commentCount', index:'a.comment_count', width:150, align:"center"},
		{header:'${text('商品重量克为单位')}', name:'weight', index:'a.weight', width:150, align:"center"},
		{header:'${text('商品体积。单位立方米')}', name:'volume', index:'a.volume', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('市场价')}', name:'marketPrice', index:'a.market_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('本店价')}', name:'shopPrice', index:'a.shop_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('商品成本价')}', name:'costPrice', index:'a.cost_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('价格阶梯')}', name:'priceLadder', index:'a.price_ladder', width:150, align:"left"},
		{header:'${text('商品关键词')}', name:'keywords', index:'a.keywords', width:150, align:"left"},
		{header:'${text('商品简单描述')}', name:'goodsSummary', index:'a.goods_summary', width:150, align:"left"},
		{header:'${text('商品详细描述')}', name:'goodsContent', index:'a.goods_content', width:150, align:"left"},
		{header:'${text('手机端商品详情')}', name:'mobileContent', index:'a.mobile_content', width:150, align:"left"},
		{header:'${text('商品上传原始图')}', name:'goodsLogo', index:'a.goods_logo', width:150, align:"left"},
		{header:'${text('是否为虚拟商品 1是，0否')}', name:'isVirtual', index:'a.is_virtual', width:150, align:"center"},
		{header:'${text('虚拟商品有效期')}', name:'virtualIndate', index:'a.virtual_indate', width:150, align:"center"},
		{header:'${text('虚拟商品购买上限')}', name:'virtualLimit', index:'a.virtual_limit', width:150, align:"center"},
		{header:'${text('是否允许过期退款， 1是，0否')}', name:'virtualRefund', index:'a.virtual_refund', width:150, align:"center"},
		{header:'${text('是否上架 0-未上架 1-销售中')}', name:'isOnSale', index:'a.is_on_sale', width:150, align:"center"},
		{header:'${text('是否包邮0否1是')}', name:'isFreeShipping', index:'a.is_free_shipping', width:150, align:"center"},
		{header:'${text('商品上架时间')}', name:'onTime', index:'a.on_time', width:150, align:"center"},
		{header:'${text('商品排序')}', name:'goodsSort', index:'a.goods_sort', width:150, align:"center"},
		{header:'${text('是否推荐0-未推荐 1-已推荐')}', name:'isRecommend', index:'a.is_recommend', width:150, align:"center"},
		{header:'${text('是否新品0-不是 1-是')}', name:'isNew', index:'a.is_new', width:150, align:"center"},
		{header:'${text('是否热卖')}', name:'isHot', index:'a.is_hot', width:150, align:"center"},
		{header:'${text('商品所属类型id，取值表goods_type的id')}', name:'goodsType', index:'a.goods_type', width:150, align:"center"},
		{header:'${text('商品规格类型，取值表goods_type的id')}', name:'specType', index:'a.spec_type', width:150, align:"center"},
		{header:'${text('购买商品赠送积分')}', name:'giveIntegral', index:'a.give_integral', width:150, align:"center"},
		{header:'${text('积分兑换')}', name:'exchangeIntegral', index:'a.exchange_integral', width:150, align:"center"},
		{header:'${text('供货商ID')}', name:'suppliersId', index:'a.suppliers_id', width:150, align:"center"},
		{header:'${text('商品销量')}', name:'salesSum', index:'a.sales_sum', width:150, align:"center"},
		{header:'${text('0默认1抢购2团购3优惠促销4预售5虚拟')}', name:'promType', index:'a.prom_type', width:150, align:"center"},
		{header:'${text('优惠活动id')}', name:'promId', index:'a.prom_id', width:150, align:"center"},
		{header:'${text('佣金用于分销分成')}', name:'commission', index:'a.commission', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('SPU')}', name:'spu', index:'a.spu', width:150, align:"left"},
		{header:'${text('SKU')}', name:'sku', index:'a.sku', width:150, align:"left"},
		{header:'${text('运费模板ID')}', name:'templateId', index:'a.template_id', width:150, align:"center"},
		{header:'${text('视频')}', name:'goodsVideo', index:'a.goods_video', width:150, align:"left"},
		{header:'${text('shop_id')}', name:'shopId', index:'a.shop_id', width:150, align:"left"},
		{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
		}},
		{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		{header:'${text('备注信息')}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('shop:goods:edit')){ %>
				actions.push('<a href="${ctx}/shop/goods/form?goodsId='+row.goodsId+'" class="btnList" title="${text('编辑商品')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/shop/goods/disable?goodsId='+row.goodsId+'" class="btnList" title="${text('停用商品')}" data-confirm="${text('确认要停用该商品吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/shop/goods/enable?goodsId='+row.goodsId+'" class="btnList" title="${text('启用商品')}" data-confirm="${text('确认要启用该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/shop/goods/delete?goodsId='+row.goodsId+'" class="btnList" title="${text('删除商品')}" data-confirm="${text('确认要删除该商品吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>